<style>
<!--
div.satistic-profile {
	
	text-align: left;
	border:0;
}

#satistic-profile  ul{
	padding:0px;
	float:left; 
	width:100%;
	text-align: center;
	
}
#satistic-profile  ul li{
	margin:5px 30px; 

}
#satistic-profile  ul li a{
	float:left;
	width:200px;
	height:100px;
	line-height:100px;
	border:1px solid;	
}
#satistic-profile  ul li a{
	float:left;
	width:200px;
	height:100px;
	line-height:100px;
	border:1px solid;	
}
#satistic-profile  ul li a span{
	font-size:500%;
}
#satistic-views  {
	padding:20px 5px ;
	border:0;
}

#satistic-views  img{
	padding:20px 5px ;
	border:0;
}

#engine-keywords-table .engine-list{
	padding: 10px 10px 0 10px;
	background:#fff;
	width:360px;
	border:1px solid;
   -moz-border-radius: 5px;
    -webkit-border-radius: 5px;
} 
-->
</style>
<?php
extract ($data);

$weekly = array_slice($monthly,-7);?>
<div class='satistic-profile'>

<ul class='menu'>
	<li><a href="#satistic-views">
		<span class='count views-count today' ><?php echo array_sum($today)?></span>
		<span class='count views-count weekly'><?php echo array_sum($weekly)?></span>
		<span class='count views-count monthly'><?php echo array_sum($monthly)?></span>
		<span class='count views-count yearly'><?php echo array_sum($yearly)?></span>
	访问次数</a></li>
	<!-- <li><a href="#satistic-from">访问</a></li> -->
	<li><a href="#satistic-link">
		<span class='' ><?php echo $link_count;?></span>
		访问来源</a></li>
</ul>
<div id='satistic-views'> 
<?php echo CHtml::dropDownList('','yearly',array('today' =>'今天--'.date('Y-m-d'),
											'weekly' =>'一周内',
											'monthly'=>'一月内',
											'yearly' =>'一年内',),
									array('class'=>'','id'=>'duraption-selector'))?>
<div class='count views-count today'><?php echo CHtml::image ( CUtilHelper::chartLink ( $today, array_keys ( $today ) ));?></div>
<div class='count views-count weekly'><?php echo CHtml::image ( CUtilHelper::chartLink ( $weekly, array_keys ( $weekly ) )  );?></div>
<div class='count views-count monthly'><?php echo CHtml::image ( CUtilHelper::chartLink ( $monthly, array_keys ( $monthly )) );?></div>
<div class='count views-count yearly'><?php echo CHtml::image ( CUtilHelper::chartLink ( $yearly, array_keys ( $yearly )) );?></div>
 </div>
<div id='satistic-from'> </div>
<div id='satistic-link'>

	<div class='span-10'>
		<h3>Referer</h3>
		<table>
			<tr><th>网址</th><th style='width:50px;'>次数</th></tr>
			<?php foreach($links as $link): ?>
			<tr><td><?php echo CHtml::link($link->refer,$link->refer,array('target'=>'_blank'));?></td><td><?php echo $link->count;?></td></tr>
			<?php endforeach;?>
		</table>
	 
	</div>
	<div class='span-10'>
		<h3>Engine</h3>
		<table id='engine-keywords-table'>
			<tr><th><?php echo '搜索关键字'?></th><th style='width:50px;'><?php echo '次数'?></th></tr>
			<?php foreach($keywords as $keyword):?>
			<tr name='<?php echo md5($keyword->keyword);?>'><td><?php echo $keyword->keyword;?>
			<div id='<?php echo md5($keyword->keyword);?>' class="engine-list" style='display:none;'>
				<table >
					<?php foreach($keyword->hosts as $host=>$count):?>
					<tr><td><?php echo $keyword->keyword;?></td><td><?php echo str_replace('_','.',$host);?></td><td><span class='right'><?php echo $count;?></span></td></tr>
					<?php endforeach;?>
				</table>
			</div>
			</td><td><?php echo $keyword->count;?></td></tr>
			<?php endforeach;?>
		</table>
		
	 
	</div>
 </div>

</div>

<script type="text/javascript">
<!--

//$( "#satistic-wrap" ).tabs({selected:0});
$("div.satistic-profile" ).tabs({selected:0});

$(function() {
	$("table#engine-keywords-table tr" )
			.has('td')
			.hover(function(){ 
						$('#'+ $(this).attr('name')).css({position:'absolute','margin-left':'50px'}).show();
						},
				function(){
							$('#'+ $(this).attr('name')).hide();
						}
	);
});
//init 
function selectChange(event){

	$("div.satistic-profile .count" ).hide();
	var selected = $("#duraption-selector option:selected").val();
	$("div.satistic-profile ."+selected ).show();
}
$("#duraption-selector").bind('change',selectChange);
selectChange();
//-->
</script>